package com.tanhua.model.vo;

import com.tanhua.model.domain.Announcement;
import com.tanhua.model.domain.BasePojo;
import com.tanhua.model.domain.UserInfo;
import com.tanhua.model.mongo.RecommendUser;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author ck
 * @date 2021/11/16 22:00
 */

@Data
@NoArgsConstructor
@AllArgsConstructor
public class AnnouncementVo implements Serializable {

    //通告id
    private String id;
    //通告标题
    private String title;
    //通告描述
    private String description;
    //创建时间
    private String createDate;

    /**
     * 在vo对象中，补充一个工具方法，封装转化过程
     */
    public static AnnouncementVo init(Announcement announcement) {
        AnnouncementVo vo = new AnnouncementVo();
        BeanUtils.copyProperties(announcement,vo);
        vo.setId(announcement.getId().toString());
        vo.setCreateDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(announcement.getCreated()));
        return vo;
    }
}
